/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import datos.cliente;
import javax.swing.*;
import negocio.ui.uiClinica;

/**
 *
 * @author David
 */
public class AgregarTratamientoFrame extends javax.swing.JFrame {

    
    /*
     * Esta variable almacena la accion a realizar:
     * 0 = Agregar
     * 1 = Modificar
     */
    private int accion_tratamineto = 0;
    private int id_tratamiento = 0; //USADO A LA HORA DE MODIFICAR
    private cliente c = null;
    uiClinica ui = uiClinica.getInstance();
    /**
     * Creates new form AgregarTratamientoFrame
     */
    public AgregarTratamientoFrame() {
        initComponents();
        this.pack();
        
        //MODIFICACIONE SEGUN ACCION
        reset();      
    }
    
    public void clear() {
        this.txt_desc_tratamiento.setText("");
        this.txt_indicaciones_tratamiento.setText("");
        this.txt_pieza_tratamiento.setText("");
    }
    
    public void reset(){
        if(accion_tratamineto == 0){
            btn_agregarTratamineto.setText("Agregar");
        }else if(accion_tratamineto == 1){
            btn_agregarTratamineto.setText("Modificar.");
        }//if  
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        main_agregarTratamiento = new javax.swing.JPanel();
        title_tratamineto = new javax.swing.JLabel();
        sep_tratamiento = new javax.swing.JSeparator();
        label_pieza = new javax.swing.JLabel();
        label_desc = new javax.swing.JLabel();
        label_indicaciones = new javax.swing.JLabel();
        txt_pieza_tratamiento = new javax.swing.JTextField();
        scroll_desc_tratamiento = new javax.swing.JScrollPane();
        txt_desc_tratamiento = new javax.swing.JTextArea();
        scroll_indicaciones_tratamiento = new javax.swing.JScrollPane();
        txt_indicaciones_tratamiento = new javax.swing.JTextArea();
        btn_agregarTratamineto = new javax.swing.JButton();
        menubar_tratamientos = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        Menu_cerrar = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        main_agregarTratamiento.setBackground(new java.awt.Color(255, 255, 255));

        title_tratamineto.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        title_tratamineto.setText("Tratamiento");

        label_pieza.setText("Pieza:");

        label_desc.setText("Descripcion:");

        label_indicaciones.setText("Indicaciones:");

        txt_desc_tratamiento.setColumns(20);
        txt_desc_tratamiento.setRows(5);
        scroll_desc_tratamiento.setViewportView(txt_desc_tratamiento);

        txt_indicaciones_tratamiento.setColumns(20);
        txt_indicaciones_tratamiento.setRows(5);
        scroll_indicaciones_tratamiento.setViewportView(txt_indicaciones_tratamiento);

        btn_agregarTratamineto.setText("Guardar");
        btn_agregarTratamineto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregarTrataminetoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout main_agregarTratamientoLayout = new javax.swing.GroupLayout(main_agregarTratamiento);
        main_agregarTratamiento.setLayout(main_agregarTratamientoLayout);
        main_agregarTratamientoLayout.setHorizontalGroup(
            main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(main_agregarTratamientoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sep_tratamiento)
                    .addGroup(main_agregarTratamientoLayout.createSequentialGroup()
                        .addComponent(title_tratamineto)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btn_agregarTratamineto))
                    .addGroup(main_agregarTratamientoLayout.createSequentialGroup()
                        .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_desc)
                            .addComponent(label_indicaciones)
                            .addComponent(label_pieza))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txt_pieza_tratamiento)
                            .addComponent(scroll_desc_tratamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                            .addComponent(scroll_indicaciones_tratamiento))))
                .addContainerGap())
        );
        main_agregarTratamientoLayout.setVerticalGroup(
            main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(main_agregarTratamientoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(title_tratamineto)
                    .addComponent(btn_agregarTratamineto))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sep_tratamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_pieza)
                    .addComponent(txt_pieza_tratamiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_desc)
                    .addComponent(scroll_desc_tratamiento, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(main_agregarTratamientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(main_agregarTratamientoLayout.createSequentialGroup()
                        .addComponent(label_indicaciones)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(scroll_indicaciones_tratamiento, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE))
                .addContainerGap())
        );

        jMenu1.setText("Archivo");

        Menu_cerrar.setText("Cerrar");
        Menu_cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Menu_cerrarActionPerformed(evt);
            }
        });
        jMenu1.add(Menu_cerrar);

        menubar_tratamientos.add(jMenu1);

        setJMenuBar(menubar_tratamientos);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(main_agregarTratamiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(main_agregarTratamiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_agregarTrataminetoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregarTrataminetoActionPerformed
        //AGREGAR
        if(accion_tratamineto == 0){
            ui.agregarTratamiento(this);
            
        //MODIFICAR
        }else if(accion_tratamineto == 1){
            ui.modificar_tratamiento(this);
        }
    }//GEN-LAST:event_btn_agregarTrataminetoActionPerformed

    private void Menu_cerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Menu_cerrarActionPerformed
       this.setVisible(false);
       this.clear();
    }//GEN-LAST:event_Menu_cerrarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AgregarTratamientoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AgregarTratamientoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AgregarTratamientoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AgregarTratamientoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AgregarTratamientoFrame().setVisible(true);
            }
        });
    }

    public JButton getBtn_agregarTratamineto() {
        return btn_agregarTratamineto;
    }

    public void setBtn_agregarTratamineto(JButton btn_agregarTratamineto) {
        this.btn_agregarTratamineto = btn_agregarTratamineto;
    }

    public JLabel getLabel_desc() {
        return label_desc;
    }

    public void setLabel_desc(JLabel label_desc) {
        this.label_desc = label_desc;
    }

    public JLabel getLabel_indicaciones() {
        return label_indicaciones;
    }

    public void setLabel_indicaciones(JLabel label_indicaciones) {
        this.label_indicaciones = label_indicaciones;
    }

    public JLabel getLabel_pieza() {
        return label_pieza;
    }

    public void setLabel_pieza(JLabel label_pieza) {
        this.label_pieza = label_pieza;
    }

    public JPanel getMain_agregarTratamiento() {
        return main_agregarTratamiento;
    }

    public void setMain_agregarTratamiento(JPanel main_agregarTratamiento) {
        this.main_agregarTratamiento = main_agregarTratamiento;
    }

    public JMenuBar getMenubar_tratamientos() {
        return menubar_tratamientos;
    }

    public void setMenubar_tratamientos(JMenuBar menubar_tratamientos) {
        this.menubar_tratamientos = menubar_tratamientos;
    }

    public JScrollPane getScroll_desc_tratamiento() {
        return scroll_desc_tratamiento;
    }

    public void setScroll_desc_tratamiento(JScrollPane scroll_desc_tratamiento) {
        this.scroll_desc_tratamiento = scroll_desc_tratamiento;
    }

    public JScrollPane getScroll_indicaciones_tratamiento() {
        return scroll_indicaciones_tratamiento;
    }

    public void setScroll_indicaciones_tratamiento(JScrollPane scroll_indicaciones_tratamiento) {
        this.scroll_indicaciones_tratamiento = scroll_indicaciones_tratamiento;
    }

    public JSeparator getSep_tratamiento() {
        return sep_tratamiento;
    }

    public void setSep_tratamiento(JSeparator sep_tratamiento) {
        this.sep_tratamiento = sep_tratamiento;
    }

    public JLabel getTitle_tratamineto() {
        return title_tratamineto;
    }

    public void setTitle_tratamineto(JLabel title_tratamineto) {
        this.title_tratamineto = title_tratamineto;
    }

    public JTextArea getTxt_desc_tratamiento() {
        return txt_desc_tratamiento;
    }

    public void setTxt_desc_tratamiento(JTextArea txt_desc_tratamiento) {
        this.txt_desc_tratamiento = txt_desc_tratamiento;
    }

    public JTextArea getTxt_indicaciones_tratamiento() {
        return txt_indicaciones_tratamiento;
    }

    public void setTxt_indicaciones_tratamiento(JTextArea txt_indicaciones_tratamiento) {
        this.txt_indicaciones_tratamiento = txt_indicaciones_tratamiento;
    }

    public JTextField getTxt_pieza_tratamiento() {
        return txt_pieza_tratamiento;
    }

    public void setTxt_pieza_tratamiento(JTextField txt_pieza_tratamiento) {
        this.txt_pieza_tratamiento = txt_pieza_tratamiento;
    }

    public int getAccion_tratamineto() {
        return accion_tratamineto;
    }

    public void setAccion_tratamineto(int accion_tratamineto) {
        this.accion_tratamineto = accion_tratamineto;
    }

    public cliente getC() {
        return c;
    }

    public void setC(cliente c) {
        this.c = c;
    }

    public int getId_tratamiento() {
        return id_tratamiento;
    }

    public void setId_tratamiento(int id_tratamiento) {
        this.id_tratamiento = id_tratamiento;
    }
    
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Menu_cerrar;
    private javax.swing.JButton btn_agregarTratamineto;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JLabel label_desc;
    private javax.swing.JLabel label_indicaciones;
    private javax.swing.JLabel label_pieza;
    private javax.swing.JPanel main_agregarTratamiento;
    private javax.swing.JMenuBar menubar_tratamientos;
    private javax.swing.JScrollPane scroll_desc_tratamiento;
    private javax.swing.JScrollPane scroll_indicaciones_tratamiento;
    private javax.swing.JSeparator sep_tratamiento;
    private javax.swing.JLabel title_tratamineto;
    private javax.swing.JTextArea txt_desc_tratamiento;
    private javax.swing.JTextArea txt_indicaciones_tratamiento;
    private javax.swing.JTextField txt_pieza_tratamiento;
    // End of variables declaration//GEN-END:variables

    
}
